package com.jinlejia.bbs.logic;

import android.content.Context;

import com.jinlejia.bbs.http.entity.TagDictEntity;
import com.jinlejia.bbs.http.utils.BBSConfig;
import com.jinlejia.bbs.http.utils.HttpCallBack;

import static com.jinlejia.bbs.http.utils.HttpUtils.*;

public class UserTagInfoLogic {
    private Context mContext;
    public UserTagInfoLogic(Context context){
        this.mContext = context;
    }

    public void execute(final LogicCallBack callBack){
        httpCall(BBSConfig.getTagDict).execute(httpCallBack(mContext, new HttpCallBack() {
            @Override
            public void onError(Exception e) {
                callBack.onResult(false);
            }

            @Override
            public void onResponse(JsonParse parse) {
                TagDictEntity entity = parse.parse(TagDictEntity.class);
                int flag = entity.getFlag();
                callBack.onResult(flag==2);
            }

            @Override
            public void onNoResponse(int code) {
                callBack.onResult(false);
            }
        }));
    }

    public interface LogicCallBack{
        //true: 需要设置标签 false: 不需要设置标签
        void onResult(boolean result);
    }
}
